<style>
.admin-user-icon {
    margin: 0 12px;
    cursor: pointer;
}
.ivu-dropdown-menu {
    text-align: left;
}
</style>
<template>
    <Header class="layout-header-bar">
        <Dropdown>
            <Row type="flex" justify="end" align="middle" class="code-row-bg">
                <Avatar class="admin-user-icon" shape="square" icon="ios-person" />
                <h5>我是谁</h5>
            </Row>
            <DropdownMenu slot="list">
                <DropdownItem>账户信息</DropdownItem>
                <DropdownItem disabled>修改密码</DropdownItem>
                <DropdownItem>
                    <span @click="logoutHandle()">退出登录</span>
                </DropdownItem>
            </DropdownMenu>
        </Dropdown>
    </Header>
</template>
<script>
// import UpdatePassword from "./main-navbar-update-password";
import { clearLoginInfo } from "@/utils";
export default {
    data() {
        return {
            updatePassowrdVisible: false
        };
    },
    components: {
        // UpdatePassword
    },
    computed: {
        userName: {
            get() {
                return this.$store.state.user.name;
            }
        }
    },
    methods: {
        // 修改密码
        updatePasswordHandle() {},
        // 退出
        logoutHandle() {
            console.log("退出登录");

            this.$Modal.confirm({
                title: "Title",
                content: "<p>确定进行退出登录操作?</p>",
                onOk: () => {
                    this.$http({
                        url: "/sys/logout",
                        method: "post",
                        data: this.$http.adornData()
                    }).then(({ data }) => {
                        this.$Message.info("退出登录成功");
                        if (data && data.code === 0) {
                            clearLoginInfo();
                            this.$router.push({ name: "login" });
                        }
                    });
                },
                onCancel: () => {
                    this.$Message.info("取消操作");
                }
            });
        }
    }
};
</script>